package dubbo.server4.impl.common.disconf;

import com.baidu.disconf.client.common.annotations.DisconfFile;
import com.baidu.disconf.client.common.annotations.DisconfFileItem;
import com.baidu.disconf.client.common.annotations.DisconfUpdateService;
import com.baidu.disconf.client.common.update.IDisconfUpdate;
import dubbo.server4.impl.controller.HelloWordController;
import org.apache.log4j.Logger;
import org.springframework.context.annotation.Configuration;

/**
 * Disconf 配置文件测试
 */
@Configuration
@DisconfFile(filename = "system.properties")
@DisconfUpdateService(classes = {SystemConfig.class})
public class SystemConfig  implements IDisconfUpdate {
    private Logger logger = Logger.getLogger(SystemConfig.class);
    private String url;

    @DisconfFileItem(name="url",associateField = "url")
    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    @Override
    public void reload() throws Exception {
        logger.info("start to change SystemConfig url to: " + getUrl());
    }
}
